package com.zhijiaoyun.dao;

import com.zhijiaoyun.dao.core.IBaseDao;
import com.zhijiaoyun.model.Lesson;
import com.zhijiaoyun.model.dto.LearnHistoryDto;
import org.apache.ibatis.annotations.Param;

import java.util.List;

/**
 * @author shisfish
 * @date 2017/6/6
 */
public interface ILessonDao extends IBaseDao<Lesson> {

    /**
     * get by name
     *
     * @param name
     * @return
     */
    Lesson selectByName(String name);

    /**
     * get by name not id
     *
     * @param lessonId
     * @param courseId
     * @param name
     * @return
     */
    Lesson selectByNameCourseIdNotLessonId(@Param("lessonId") long lessonId, @Param("courseId") long courseId,
                                           @Param("name") String name);

    /**
     * count by params
     *
     * @param courseId
     * @param name
     * @param title
     * @return
     */
    int countByParams(@Param("courseId") long courseId, @Param("name") String name, @Param("title") String title);

    /**
     * page by params
     *
     * @param beginIndex
     * @param pageSize
     * @param courseId
     * @param name
     * @param title
     * @return
     */
    List<Lesson> pageByParams(@Param("beginIndex") int beginIndex, @Param("pageSize") int pageSize,
                              @Param("courseId") long courseId, @Param("name") String name, @Param("title") String title);

    /**
     * get by courseId and name
     *
     * @param courseId
     * @param name
     * @return
     */
    Lesson selectByNameCourseId(@Param("courseId") long courseId, @Param("name") String name);

    /**
     * list by courseId
     *
     * @param courseId
     * @return
     */
    List<Lesson> selectLessonByCourseId(Long courseId);

    /**
     * list dto by userId and courseId
     *
     * @param userId
     * @param courseId
     * @return
     */
    List<LearnHistoryDto> selectLessonHistory(@Param("userId") Long userId, @Param("courseId") Long courseId);

    /**
     * get by lessonId and courseId
     *
     * @param lessonId
     * @param courseId
     * @return
     */
    Lesson selectByLessonIdCourseId(@Param("lessonId") Long lessonId, @Param("courseId") Long courseId);

    /**
     * list by params
     *
     * @param courseId
     * @param name
     * @param title
     * @return
     */
    List<Lesson> selectByParams(@Param("courseId") Long courseId, @Param("name") String name, @Param("title") String title);

    /**
     * count all
     *
     * @return
     */
    int countAll();

    /**
     * 获取start-end之间的数据
     *
     * @param start
     * @param end
     * @param courseId
     * @return
     */
    List<Lesson> listBetweenSort(@Param("start") int start, @Param("end") int end, @Param("courseId") long courseId);

    /**
     * 更新排序
     *
     * @param lessonList
     * @param createUser
     */
    void updateSort(@Param("lessonList") List<Lesson> lessonList, @Param("createUser") String createUser);

    /**
     * H偶去sort之后的数据
     *
     * @param sort
     * @param courseId
     * @return
     */
    List<Lesson> listAfterSort(@Param("sort") int sort, @Param("courseId") long courseId);
}